using UnityEditor;
using UnityEditor.UI;
using UnityEngine;

namespace Jerry.UiFrame.Editor
{
    [CanEditMultipleObjects, CustomEditor(typeof(JList), true)]
    public class JListEditor : ScrollRectEditor
    {
        private SerializedProperty grid;
        private SerializedProperty spacing;
        private SerializedProperty multiple;
        private SerializedProperty singleOff;
        private SerializedProperty forceUpdateCanvas;

        protected override void OnEnable()
        {
            base.OnEnable();
            grid = serializedObject.FindProperty("grid");
            spacing = serializedObject.FindProperty("spacing");
            multiple = serializedObject.FindProperty("multiple");
            singleOff = serializedObject.FindProperty("singleOff");
            forceUpdateCanvas = serializedObject.FindProperty("forceUpdateCanvas");
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();
         
            EditorGUILayout.PropertyField(grid);
            EditorGUILayout.PropertyField(spacing);    
            EditorGUILayout.PropertyField(multiple);
            EditorGUILayout.PropertyField(singleOff);
            
            // 自定义红色��式
            Color originalColor = GUI.color;
            GUI.color = Color.red;
            EditorGUILayout.PropertyField(forceUpdateCanvas);
            GUI.color = originalColor;
            serializedObject.ApplyModifiedProperties();

            base.OnInspectorGUI();
        }
    }
}